import{
    ADD_COUNTER,
    GETADDGOUWU_C
} from './mutation-types'
export default {
    addCart(context, paylod) {
        return new Promise((resolve, reject) => {
            let oldProduct = context.state.cartList.find( item => item.iid === paylod.iid)
            if(oldProduct) {
             context.commit(ADD_COUNTER, oldProduct)
             resolve('商品数量+1')
            }else{
             paylod.count = 1 
             context.commit(GETADDGOUWU_C, paylod)
             resolve('添加商品')
            }
        })
        
      } 
}